var t = require("../../../utils/themeSkin/skinBehavior"), a = getApp();

Page({
    behaviors: [ t ],
    data: {
        rankingList: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        city: "",
        cityCode: "",
        latitude: "",
        longitude: "",
        imageUrl: ""
    },
    onLoad: function(t) {
        t.city ? this.data.city = t.city : this.data.cityCode = t.cityCode, this.data.longitude = t.longitude, 
        this.data.latitude = t.latitude, this.getGoodsByShowSales();
    },
    onReady: function() {},
    rankingNavTo: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageF/tourAround/tourAroundGoodsDetails/tourAroundGoodsDetails?goodsId=".concat(a, "&longitude=").concat(this.data.longitude, "&latitude=").concat(this.data.latitude)
        });
    },
    getGoodsByShowSales: function() {
        var t = this, o = a.getNetAddresss("plugin.travel-around.frontend.index.index.getGoodsByShowSales");
        a._postNetWork({
            url: o,
            data: {
                city: this.data.city,
                cityCode: this.data.cityCode,
                basic_info: 1
            },
            success: function(a) {
                var o, i, e = a.data, n = e.basic_info;
                (wx.hideLoading(), wx.hideNavigationBarLoading(), wx.stopPullDownRefresh(), 1 == e.result) ? (t.data.totalPage = e.data.last_page, 
                t.data.totalPage || (t.data.totalPage = 0), t.setData({
                    rankingList: e.data.data,
                    imageUrl: null == n || null === (o = n.home) || void 0 === o || null === (i = o.mailInfo) || void 0 === i ? void 0 : i.logo_url
                })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                }));
                wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: t.data.themeBaseColor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.totalPage)) {
            this.data.page = this.data.page + 1;
            var o = a.getNetAddresss("plugin.travel-around.frontend.goods.goods.getGoodsList");
            a._getNetWork({
                url: o,
                data: {
                    page: this.data.page
                },
                success: function(a) {
                    var o = a.data, i = o.data.data;
                    1 == o.result ? (t.data.isLoadMore = !0, t.setData({
                        rankingList: t.data.rankingList.concat(i)
                    })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        wx.showNavigationBarLoading(), wx.showLoading({
            title: "刷新中..."
        }), this.setData({
            page: 1,
            storeName: ""
        }), this.getGoodsByShowSales();
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {
        return {
            title: "周边游排行榜",
            imageUrl: this.data.imageUrl,
            path: "/packageF/tourAround/rankingList/rankingList?cityCode=".concat(this.data.cityCode, "&city=").concat(this.data.city)
        };
    },
    onShareTimeline: function() {
        return {
            title: "周边游排行榜",
            imageUrl: this.data.imageUrl,
            path: "/packageF/tourAround/rankingList/rankingList?cityCode=".concat(this.data.cityCode, "&city=").concat(this.data.city)
        };
    }
});